<?php

/**
 * folder actions.
 *
 * @package    sf_portal
 * @subpackage folder
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 12479 2008-10-31 10:54:40Z fabien $
 */
class zdFolderActions extends sfActions
{
 
  
public function executeOpen_folder(sfWebRequest $request) {
		
		$this->cur_f = FolderPeer::retrieveByPK ( $request->getParameter ( 'id' ) );
		$this->folders = $this->cur_f->getChildren ();
		
		if( $request->getParameter ( 'width_check' )=='yes')
		$this->width_check = 'yes';

	     $this->module = $request->getParameter ( 'mod' );
		///Запоминаем открытие
		$rem = new Remember();
		$rem -> setClassName('Folder');
		$rem -> setItemId($this->cur_f->getId());
		$rem->setSessionId(session_id());
		$rem->save();
	
	}
	
     /**
	 * Закрытие каталога
	 *
	 * 
	 */
	public function executeClose_folder(sfWebRequest $request) {
		
		$this->cur_f = FolderPeer::retrieveByPK ( $request->getParameter ( 'id' ) );
		//$this->folders = $this->cur_f->getChildren ();
		 $this->module = $request->getParameter ( 'mod' );
		///Запоминаем закрытие
		$c = new Criteria();
		$c->add(RememberPeer::SESSION_ID,session_id());
		$c->addAnd(RememberPeer::ITEM_ID,$request->getParameter ( 'id' ));
		$c->addAnd(RememberPeer::CLASS_NAME,'Folder');
		RememberPeer::doDelete($c);
		if($this->cur_f->hasChildren())
		{
			$ch = $this->cur_f->getChildren();
			foreach($ch as $h)
			{
				$c = new Criteria();
				$c->add(RememberPeer::SESSION_ID,session_id());
				$c->addAnd(RememberPeer::ITEM_ID,$h->getId());
				$c->addAnd(RememberPeer::CLASS_NAME,'Folder');
				RememberPeer::doDelete($c);
			}
		}
	
			if( $request->getParameter ( 'width_check' )=='yes')
		    $this->width_check = 'yes';
		
		
	}
}
